{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Bayes criterion"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Assignment1 : Modeling "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 模型|\n",
    "$$ H=H(t)+\\epsilon  $$\n",
    "\n",
    "$$ \\epsilon \\sim  N(0,\\sigma^{2}) ,\\sigma=0.64  $$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "N=100\n",
    "T=5\n",
    "sigma=0.49\n",
    "A=5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  一些定义"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "代价因子在规则内随意取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "C00=C11=0.25\n",
    "C10=C01=0.75\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "先验函数假设"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "H0=H1=0.5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 噪声与信号\n",
    "信号我们取一个1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [],
   "source": [
    "noise=np.random.normal(0,np.sqrt(sigma),N)\n",
    "signal=np.array([1]*N)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100 100\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYX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qiWMsHSdB0AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(len(signal),len(noise))\n",
    "H=signal*A+noise\n",
    "t=np.linspace(0,T,N)\n",
    "plt.scatter(t,H)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Assignment2 : Decision Expression"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "根据书中公式11我们可以进行如下计算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "eta=H0*(C10-C00)/(H1*(C01-C00)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [],
   "source": [
    "mean=sum(H)/len(H)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [],
   "source": [
    "gamma=sigma/N/A*np.log(eta)+A/2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "if mean>gamma:\n",
    "    print(\"1\")\n",
    "else :\n",
    "    print(\"0\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在，我们将上述操作封装成函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "def signal_generate(n,H0):\n",
    "    signals=[]\n",
    "    for i in range(0,n):\n",
    "        random=np.random.random()\n",
    "        if random >H0:\n",
    "            signal=1\n",
    "        else:\n",
    "            signal=0\n",
    "        signals.append(signal)\n",
    "    return signals\n",
    "def sample(signals,N):\n",
    "    sampled_signals=[]\n",
    "    for i in signals:\n",
    "        sampled_signals.append([i]*N)\n",
    "    result =np.array(sampled_signals)\n",
    "    return result\n",
    "\n",
    "# 这里实际上是不符合流程的，应该是先进行信道传输加入噪声再采样处理\n",
    "def addnoise(sampled_signals,sigma,mean,A):\n",
    "    # print(mean,sigma)\n",
    "    noise=np.random.normal(mean,sigma,np.shape(signals_sampled))\n",
    "    noise_signal=signals_sampled*A+noise\n",
    "    # print(signals_sampled[0])\n",
    "    # print(noise[0])\n",
    "    # print(signals_sampled[0]*5+noise[0])\n",
    "    return noise_signal\n",
    "\n",
    "def decide_with_bayes(noise_signal,sigma,A,H0,C10,C11,C01,C00):\n",
    "    eta=H0*(C10-C00)/((1-H0)*(C01-C00)) \n",
    "    gamma=sigma**2/len(noise_signal)/A*np.log(eta)+A/2\n",
    "    if mean>gamma:\n",
    "        return 1 \n",
    "    else :\n",
    "        return 0 \n",
    "def evaluate(signals,noise_signals,sigma,A,H0,C10,C11,C01,C00):\n",
    "    error=0\n",
    "    for i in range(len(signals)):\n",
    "        result=decide_with_bayes(noise_signals[i],sigma,A,H0,C10,C11,C01,C00)\n",
    "        if result!=signals[i]:\n",
    "            error+=1\n",
    "    return error/len(signals)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [],
   "source": [
    "n=100\n",
    "H0=0.25\n",
    "N=100\n",
    "mean=0\n",
    "sigma=0.7\n",
    "A=5\n",
    "C10=C01=0.75\n",
    "C00=C11=0.25\n",
    "def pipeline(signals,noise_signals,sigma,A,H0,C10,C11,C01,C00):\n",
    "    signals=signal_generate(n,H0)\n",
    "    signals_sampled=sample(signals,N)\n",
    "    noise_signals=addnoise(signals_sampled,sigma,mean,A)\n",
    "    return evaluate(signals,noise_signals,sigma,A,H0,C10,C11,C01,C00)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "让我们看看结果~"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.81"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "pipeline(signals,noise_signals,sigma,A,H0,C10,C11,C01,C00)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在我们可以做个测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD6CAYAAACxrrxPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAh9UlEQVR4nO3deXxU9b3/8dcnGxAIYUuAAAFkXxMgsopaWxVUQBAF3CpaERClrfe2tr23tdre1ra/24KyiIjWWqTYggYEsbdqZZeACTsaQCAEkH1Htu/vjxk0xkAmySRnZvJ+Ph55PDIzhzmfL5O8OZz5zPmYcw4REQl/UV4XICIiwaFAFxGJEAp0EZEIoUAXEYkQCnQRkQihQBcRiRABBbqZ9TOzLWaWa2ZPFvF4opnNM7McM9tgZiODX6qIiFyJFdeHbmbRwCfAjUAesAoY4ZzbWGCbnwKJzrkfm1kSsAVo4Jw7e7nnrVevnmvWrFnZVyAiUomsXr36gHMuqajHYgL4892BXOfcNgAzmwUMAjYW2MYBCWZmQA3gEHD+Sk/arFkzsrKyAti9iIhcYmY7LvdYIKdcGgG7CtzO899X0PNAOyAfWAeMd85dLGGdIiJSBoEEuhVxX+HzNDcD2UAKkA48b2Y1v/FEZqPMLMvMsvbv31/CUkVE5EoCCfQ8oEmB243xHYkXNBKY43xyge1A28JP5Jyb5pzLcM5lJCUVeQpIRERKKZBAXwW0MrPmZhYHDAcyC22zE/g2gJnVB9oA24JZqIiIXFmxb4o6586b2ThgERANzHDObTCz0f7HpwLPAK+Y2Tp8p2h+7Jw7UI51i4hIIYF0ueCcWwAsKHTf1ALf5wM3Bbc0EREpC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JaBAFxGJEAp0EZEIoUAXEYkQCnQRkQihQBcRiRAKdBGRCKFAFxGJEP8fgQqFJhfCaDAAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "slice_=5\n",
    "result =[]\n",
    "x=[]\n",
    "for i in range(1,slice_):\n",
    "    H0_=i/slice_\n",
    "    x.append(H0_)\n",
    "    result.append(pipeline(signals,noise_signals,sigma,A,H0_,C10,C11,C01,C00))\n",
    "plt.plot(x,result)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 可以看出这是一个递减的函数，但是我认为应该是对偶函数更加合理一些，因此这个实验可能存在问题，但是代码都是按照公式敲的，**希望下节课能和老师讨论下**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1,2,6,7'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=['1','2','3','4']\n",
    "b=['5','6','7']\n",
    "','.join(a[0:-2]+b[1:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'4'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b104e73a6bc703f05e84da2cd6235ddbc2c121464bcd1bd6e4b3e43e587b3edc"
  },
  "kernelspec": {
   "display_name": "Python 3.6.8 64-bit (conda)",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
